package com.ruoyi.zsyh.controller;

import java.util.List;

import com.ruoyi.zsyh.domain.ZsyhUserRakearea;
import com.ruoyi.zsyh.service.IZsyhUserRakeareaService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单管理人管辖区域Controller
 * 
 * @author yuexl
 * @date 2021-12-21
 */
@Controller
@RequestMapping("/zsyh/rakeArea")
public class ZsyhUserRakeareaController extends BaseController
{
    private String prefix = "zsyh/rakeArea";

    @Autowired
    private IZsyhUserRakeareaService zsyhUserRakeareaService;

    @RequiresPermissions("zsyh:rakeArea:view")
    @GetMapping()
    public String rakeArea()
    {
        return prefix + "/rakeArea";
    }

    /**
     * 查询订单管理人管辖区域列表
     */
    @RequiresPermissions("zsyh:rakeArea:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhUserRakearea zsyhUserRakearea)
    {
        startPage();
        List<ZsyhUserRakearea> list = zsyhUserRakeareaService.selectZsyhUserRakeareaList(zsyhUserRakearea);
        return getDataTable(list);
    }

    /**
     * 导出订单管理人管辖区域列表
     */
    @RequiresPermissions("zsyh:rakeArea:export")
    @Log(title = "订单管理人管辖区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhUserRakearea zsyhUserRakearea)
    {
        List<ZsyhUserRakearea> list = zsyhUserRakeareaService.selectZsyhUserRakeareaList(zsyhUserRakearea);
        ExcelUtil<ZsyhUserRakearea> util = new ExcelUtil<ZsyhUserRakearea>(ZsyhUserRakearea.class);
        return util.exportExcel(list, "订单管理人管辖区域数据");
    }

    /**
     * 新增保存订单管理人管辖区域
     */
    @RequiresPermissions("zsyh:rakeArea:add")
    @Log(title = "订单管理人管辖区域", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhUserRakearea zsyhUserRakearea)
    {
        return toAjax(zsyhUserRakeareaService.insertZsyhUserRakearea(zsyhUserRakearea));
    }

    /**
     * 修改订单管理人管辖区域
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhUserRakearea zsyhUserRakearea = zsyhUserRakeareaService.selectZsyhUserRakeareaById(id);
        mmap.put("zsyhUserRakearea", zsyhUserRakearea);
        return prefix + "/edit";
    }

    /**
     * 修改保存订单管理人管辖区域
     */
    @RequiresPermissions("zsyh:rakeArea:edit")
    @Log(title = "订单管理人管辖区域", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhUserRakearea zsyhUserRakearea)
    {
        return toAjax(zsyhUserRakeareaService.updateZsyhUserRakearea(zsyhUserRakearea));
    }

    /**
     * 删除订单管理人管辖区域
     */
    @RequiresPermissions("zsyh:rakeArea:remove")
    @Log(title = "订单管理人管辖区域", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhUserRakeareaService.deleteZsyhUserRakeareaByIds(ids));
    }
}
